<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>签约网</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/style.css" />
    <link rel="stylesheet" type="text/css" href="../css/lawyer_user.css" />
    <link rel="stylesheet" type="text/css" href="../css/baguetteBox.css" />
    <script type="text/javascript" src="../script/api.js"></script>
    <script type="text/javascript" src="../script/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="../script/mobile.js"></script>
    <script type="text/javascript" src="../script/baguetteBox.js"></script>
    <script type="text/javascript" src="../script/highlight.min.js"></script>
    <script type="text/javascript" src="../script/lawyer.js"></script>
    <script type="text/javascript">
        window['adaptive'].desinWidth = 750;
        window['adaptive'].baseFont = 28;
        window['adaptive'].maxWidth = 750;
        window['adaptive'].init();
    </script>
    <style type="text/css">
        .zhuanfa{
            padding: 0.2rem 0.1rem;
            background: #f1f1f1;
        }
        .zfInfo{
            font-size: 0.28rem;
            line-height: 0.4rem;
        }
        .zfInfo span{
            color: #1c83ea;
        }
        .zhuanfaImg dl{
            display: flex;
            margin-top: 0.2rem;
        }
        .zhuanfaImg dl dd{
            width: 31%;
            margin-right: 3%;
        }
        .zhuanfaImg dl dd:last-child{
            margin-right: 0;
        }
        .zhuanfaImg dl dd img{
            display: block;
            width: 2.2rem;
            height: 2.2rem;
        }
    </style>
</head>
<body>
<header class="header">
    <a href="javascript:void(0);" onclick="comeBack()" class="back_btn"><img src="../image/head-fanhui.png" alt=""></a>
    <h2>转发</h2>
    <!--<a href="find_lawyers_edit.html" class="myAnswer_btn edit_btn"><img src="../image/edit_icon.png" alt=""></a>-->
</header>
<section class="dynamic_form" style="border-bottom: none!important;">
    <form action="">
        <textarea style='width:100%; padding-top: 0.1rem;' name="" id="content" cols="30" rows="10" placeholder="请输入转发内容"></textarea>
        <div class="zhuanfa">
            <div class="zfInfo">
                <p><span>律师名字：</span>内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容</p>
            </div>
            <div class="zhuanfaImg">
                <dl>
                    <dd><img src="../image/photos1.jpg" alt=""></dd>
                    <dd><img src="../image/photos1.jpg" alt=""></dd>
                    <dd><img src="../image/photos1.jpg" alt=""></dd>
                </dl>
            </div>
        </div>
    </form>
</section>
<section class="fixed_btn">
    <a href="javascript:void(0)"  onclick="tijiao()">确认转发</a>
</section>

</body>
<script>
    var para
    var id
    apiready = function () {

        para=api.pageParam
        id=para.id
        if(id>0){
            dongtai()
        }


    };

    function dongtai() {
        var p={model:'dongtai',id:id};
        api.ajax({
            url: webSiteUrl+'/app/home/find',
            method: 'post',
            data: {
                values:p,
            }
        }, function(ret, err) {
            if(ret.code==200){
              console.log(JSON.stringify(ret));
                //$('#content').val(ret.data.content);
                $('.zfInfo').html('<p><span onclick="dtdetail('+ret.data.id+')">'+ret.data.name+'：</span>'+ret.data.content+'</p>');

                var str = '';
                if(ret.data.icon.length>0){
                    for( var i=0;i<ret.data.icon.length;i++){
                        str+='<dd><img src="'+webSiteUrl+ret.data.icon[i]+'" alt=""></dd>'
                    }
                    $(".zhuanfaImg dl").html(str)
                }else{
                  $(".zhuanfaImg dl").html('')
                }

            }else{
                alert(ret.msg)
            }
        });

    }
    function dtdetail(id){
        api.openWin({
            name: 'lawyer_dynamic_details',
            url:  'lawyer_dynamic_details.html',
            reload: true,
            pageParam: {
                id: id
            }
        });
    }
    function tijiao(){
        if(!loginCheck()){
            return;
        }
        var content=$('#content').val();

        if(content==''){
            api.alert({msg:"请输入内容！"});return;
        }
//alert(icon);
        var para=api.pageParam

        var  p={token:token,content:content,id:para.id};

        api.ajax({
            url: webSiteUrl+'/app/user/adddongtai',
            method: 'post',
            data: {
                values:p,
            }
        }, function(ret, err) {
            api.hideProgress();

            if(ret.code==200){
                alert(ret.msg);
                api.openWin({
                    name: 'lawyerquan',
                    url: './lawyerquan.html',
                    reload:true,
                    pageParam: {

                    }
                });
            }else{
                alert(ret.msg)
            }

        });
    }
function showAction() {
    var len=$('#imgcon').children().length;
    if(len==3){
        alert("最多上传3张图片");return;
    }
    api.actionSheet({
         title: '上传图片',
         cancelTitle: '取消',
         buttons: ['拍照', '从手机相册选择']
    }, function(ret, err) {
         if (ret) {
             getPicture(ret.buttonIndex);
         }
    });
}
function getPicture(sourceType) {
        if (sourceType == 1) { // 拍照
            //获取一张图片
            api.getPicture({
                sourceType: 'camera',
                encodingType: 'png',
                mediaValue: 'pic',
                allowEdit: false,
                quality: 90,
                saveToPhotoAlbum: true
            }, function(ret, err) {
                if(ret.data==''){return;}
                if (ret) {

                    var imgSrc = ret.data;
                    if (imgSrc != "") {

                        //$api.attr(ele, 'src', imgSrc);
                    }
                    if (ret.hasOwnProperty("list")) {

                        //var localAvaterPath = ret.data;
                        //$api.attr(ele, 'src', ret.list[0].path);
                        api.showProgress({
                            title: '正在上传...',
                            modal: true
                        });
                    }
                    var ele = $api.dom('#icon');
                    api.ajax({
                        url: webSiteUrl+'/app/public/uploads',
                        method: 'post',
                        data: {
                            files: {
                                'file': ret.data,
                            }
                        }
                    }, function(ret, err) {
                        if (ret) {
                            if (ret.code == 200) {
                                //alert(JSON.stringify(ret));
                                api.hideProgress();



                                addpic(ret.id,ret.pic);



                            } else {
                                api.hideProgress();
                                api.toast({
                                    msg: ret.msg,
                                    location: 'middle'
                                });
                            }
                        } else {
                            api.hideProgress();
                            api.toast({
                                msg: err.msg,
                                location: 'middle'
                            });
                        }
                    });




                }
            });
        } else if (sourceType == 2) { // 从相机中选择
            //UIMediaScanner 是一个多媒体扫描器，可扫描系统的图片、视频等多媒体资源
            var obj = api.require('UIMediaScanner');
            obj.open({
                //返回的资源种类,picture（图片）,video（视频）,all（图片和视频）
                type: 'picture',
                //（可选项）图片显示的列数，须大于1
                column: 4,
                max: 1,
                //（可选项）图片排序方式,asc（旧->新）,desc（新->旧）
                sort: {
                    key: 'time',
                    order: 'desc'
                },
                //（可选项）模块各部分的文字内容
                texts: {
                    stateText: '已选择*项',
                    cancelText: '取消',
                    finishText: '完成'
                },
                styles: {
                    bg: '#fff',
                    mark: {
                        icon: '',
                        position: 'bottom_right',
                        size: 20
                    },
                    nav: {
                        bg: '#eee',
                        stateColor: '#000',
                        stateSize: 18,
                        cancleBg: 'rgba(0,0,0,0)',
                        cancelColor: '#000',
                        cancelSize: 18,
                        finishBg: 'rgba(0,0,0,0)',
                        finishColor: '#000',
                        finishSize: 18
                    }
                }
            }, function(ret) {
                if(ret.eventType=='cancel'){return;}
                if (ret) {
                    if (ret.hasOwnProperty("list")) {

                        //var localAvaterPath = ret.list[0].path;
                        //$api.attr(ele, 'src', ret.list[0].path);
                        api.showProgress({
                            title: '正在上传...',
                            modal: true
                        });
                    }
                    var ele = $api.dom('#icon');
                    api.ajax({
                        url: webSiteUrl+'/app/public/uploads',
                        method: 'post',
                        data: {
                            files: {
                                'file': ret.list[0].path,
                            }
                        }
                    }, function(ret, err) {
                        if (ret) {
                            if (ret.code == 200) {
                                api.hideProgress();
                                //alert(JSON.stringify(ret));


                                addpic(ret.id,ret.pic);

                            } else {
                                api.hideProgress();
                                api.toast({
                                    msg: ret.msg,
                                    location: 'middle'
                                });
                            }
                        } else {
                            api.hideProgress();
                            api.toast({
                                msg: err.msg,
                                location: 'middle'
                            });
                        }
                    });





                }
            });
        }
    }
    function addpic(id,imgpath){

        var ids=$("#iconid").val();


        if(ids != ''){
            ids+=','+id;
        }else{
            ids=id;
        }
        $("#iconid").val(ids);

        var a='<img src="'+webSiteUrl+imgpath+'" style="display:inline-block"/>';

        $("#imgcon").append(a);

    }
</script>
</html>
